@extends('admin.common.framework') 
@section('content')
<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header">管理菜单设置</h3>
    </div>
    <!-- /.col-lg-12 -->
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                菜单列表
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover" id="menu-table">
                        <thead>
                            <tr>
                                <th class="col-lg-1">#</th>
                                <th class="col-lg-4">菜单名称</th>
                                <th class="col-lg-4">菜单路径</th>
                                <th class="col-lg-3">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($list as $li)
                            <tr class="parent-menu" data-id="{{$li['id']}}" data-pid="{{$li['pid']}}" data-isdown="0" id="menu-{{$li['id']}}">
                                <td class="down"><span class="fa fa-fw fa-angle-right"></span></td>
                                <td>{{ $li['title'] }}</td>
                                <td>{{$li['url']}}</td>
                                <td>
                                    <span class="fa fa-fw fa-plus-square-o add-span fa-action" title="添加" data-toggle="modal" data-target="#menu-add-modal" data-id="{{$li['id']}}"></span>
                                    <span class="fa fa-fw fa-edit edit-span fa-action" title="修改" data-toggle="modal" data-target="#menu-edit-modal" data-id="{{$li['id']}}" data-isshow="{{$li['isshow']}}"
                                        data-status="{{$li['status']}}" data-icon="{{$li['icon']}}" data-url="{{$li['url']}}"
                                        data-title="{{$li['title']}}" data-pid="{{$li['pid']}}" data-rank="{{$li['rank']}}"></span>
                                        <span class="fa fa-fw fa-trash-o del-span fa-action" title="删除"  data-id="{{$li['id']}}"></span>
                                    </td>
                            </tr>
                            @isset($li['children']) @foreach ($li['children'] as $ch )
                            <tr id="menu-{{$ch['id']}}" class="children-menu" data-id="{{$ch['id']}}" data-pid="{{$ch['pid']}}">
                                <td><span class="fa fa-fw fa-angle-double-right"></span></td>
                                <td>{{ $ch['title'] }}</td>
                                <td>{{$ch['url']}}</td>
                                <td>
                                    <span class="fa fa-fw fa-plus-square-o add-span fa-action" title="添加" data-toggle="modal" data-target="#menu-add-modal" data-id="{{$ch['pid']}}"></span>
                                    <span class="fa fa-fw fa-edit edit-span fa-action" title="修改" data-toggle="modal" data-target="#menu-edit-modal" data-id="{{$ch['id']}}" data-isshow="{{$ch['isshow']}}"
                                        data-status="{{$ch['status']}}" data-icon="{{$ch['icon']}}" data-url="{{$ch['url']}}"
                                        data-title="{{$ch['title']}}" data-pid="{{$ch['pid']}}" data-rank="{{$ch['rank']}}"></span>
                                        <span class="fa fa-fw fa-trash-o del-span fa-action" title="删除"  data-id="{{$ch['id']}}"></span>
                                    </td>
                            </tr>
                            @endforeach @endisset @endforeach
                        </tbody>
                    </table>
                </div>
                <!-- /.table-responsive -->
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
</div>
<div>
    <!-- Modal -->
    <div class="modal fade" id="menu-add-modal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="addModalLabel">菜单添加</h4>
                </div>
                <div class="modal-body" style="padding:30px;">
                    <div class="row">
                        <div class="col-lg-12">
                            <form role="form" id="menu-add-form">
                                {{ csrf_field() }}
                                <div class="form-group">
                                    <label>父级菜单</label>
                                    <select class="form-control" name="pid">
                                        <option value="0" selected="selected">顶级菜单</option>
                                        @foreach ($list as $li)
                                        <option value="{{$li['id']}}">{{$li['title']}}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>菜单名称</label>
                                    <input class="form-control" name="title" type="text">
                                </div>
                                <div class="form-group">
                                    <label>图标</label>
                                    <input class="form-control" name="icon" type="text">
                                </div>
                                <div class="form-group">
                                    <label>URL</label>
                                    <input class="form-control" name="url" tpye="text">
                                </div>
                                <div class="form-group">
                                    <label>排序</label>
                                    <input class="form-control" name="rank" type="number" value="0">
                                </div>
                                <div class="form-group">
                                    <label style="margin-right:25px;">显示</label>
                                    <label class="radio-inline">
                                        <input type="radio" name="isshow" id="isshow-1" value="1" checked>显示
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="isshow" id="isshow-0" value="0">隐藏
                                    </label>
                                </div>
                                <div class="form-group">
                                    <label style="margin-right:25px;">状态</label>
                                    <label class="radio-inline">
                                            <input type="radio" name="status" id="status-1" value="1" checked>启用
                                        </label>
                                    <label class="radio-inline">
                                            <input type="radio" name="status" id="status-0" value="0">关闭
                                        </label>
                                </div>
                            </form>
                        </div>
                        <!-- /.col-lg-6 (nested) -->
                        <!-- /.col-lg-6 (nested) -->
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="reset" class="btn btn-default" data-dismiss="modal" id="menu-add-reset">关闭</button>
                    <button type="button" class="btn btn-primary submit" id="menu-add-submit">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="menu-edit-modal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="editModalLabel">菜单修改</h4>
                </div>
                <div class="modal-body" style="padding:30px;">
                    <div class="row">
                        <div class="col-lg-12">
                            <form role="form" id="menu-edit-form">
                                {{ csrf_field() }}
                                <input type="hidden" name="id" value="">
                                <div class="form-group">
                                    <label>父级菜单</label>
                                    <select class="form-control" name="pid">
                                                <option value="0" selected="selected">顶级菜单</option>
                                                @foreach ($list as $li)
                                                <option value="{{$li['id']}}">{{$li['title']}}</option>
                                                @endforeach
                                            </select>
                                </div>
                                <div class="form-group">
                                    <label>菜单名称</label>
                                    <input class="form-control" name="title" type="text" required>
                                </div>
                                <div class="form-group">
                                    <label>图标</label>
                                    <input class="form-control" name="icon" type="text">
                                </div>
                                <div class="form-group">
                                    <label>URL</label>
                                    <input class="form-control" name="url" tpye="text" required>
                                </div>
                                <div class="form-group">
                                    <label>排序</label>
                                    <input class="form-control" name="rank" type="number" value="0">
                                </div>
                                <div class="form-group">
                                    <label style="margin-right:25px;">显示</label>
                                    <label class="radio-inline">
                                                <input type="radio" name="isshow" id="isshow-1" value="1" checked>显示
                                            </label>
                                    <label class="radio-inline">
                                                <input type="radio" name="isshow" id="isshow-0" value="0">隐藏
                                            </label>
                                </div>
                                <div class="form-group">
                                    <label style="margin-right:25px;">状态</label>
                                    <label class="radio-inline">
                                                    <input type="radio" name="status" id="status-1" value="1" checked>启用
                                                </label>
                                    <label class="radio-inline">
                                                    <input type="radio" name="status" id="status-0" value="0">关闭
                                                </label>
                                </div>
                            </form>
                        </div>
                        <!-- /.col-lg-6 (nested) -->
                        <!-- /.col-lg-6 (nested) -->
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="reset" class="btn btn-default" data-dismiss="modal" id="menu-edit-reset">关闭</button>
                    <button type="button" class="btn btn-primary submit" id="menu-edit-submit">提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@section('scripts')
<script src="{{ env('APP_STATIC') }}admin/js/menu.js"></script>
@endsection